<template>
    <div class="account-feedback">
        <c-wrap title="意见反馈">
            <mt-cell title="意见反馈"></mt-cell>
            <mt-field placeholder="请写你的问题或建议，欢迎您的反馈" type="textarea" rows="2" v-model="feedback.content"></mt-field>
            <div class="break"></div>
            <mt-field label="联系方式" placeholder="留下您的联系方式，方便我们联系到您" v-model="feedback.contactWay"></mt-field>
            <mt-button type="primary" style="margin-top: 40px" @click="click">提交反馈</mt-button>
        </c-wrap>
    </div>
</template>
<script>
    import CWrap from '../../components/CWrap'

    export default {
        components: {CWrap},
        data() {
            return {
                feedback: {
                    content: '',
                    contactWay: ''
                }
            }
        },
        methods: {
            click() {
                if (this.feedback.content === '') {
                    this.$toast('反馈内容不能为空！');
                    return;
                }

                if (this.feedback.contactWay === '') {
                    this.$toast('联系方式不能为空！');
                    return;
                }

                app.ajax.post(app.config.api.account.feedback, {
                    contactWay: this.feedback.contactWay,
                    content: this.feedback.content
                }, (res) => {
                    this.feedback.content = '';
                    this.feedback.contactWay = '';
                });
            }
        }
    }
</script>
<style>
    .account-feedback .mint-field.is-textarea .mint-cell-value {
        width: 100%;
        margin-right: 0;
    }

    .account-feedback .mint-field .mint-cell-value {
        width: 75%;
        margin-right: 0;
    }
</style>
